package com.task.core.domain.info;

import java.util.ArrayList;
import java.util.List;

import org.springframework.util.CollectionUtils;

import com.task.common.info.FlowFilterInfo;

import lombok.Data;

/**
 * @author 迪迦.
 * @date 2025/1/16 11:29
 */
@Data
public class ClientFlowFilterInfo {

  private Integer id;
  private String code;
  private String filterName;
  private String type;
  private String pattern;

  public static List<ClientFlowFilterInfo> getList(List<FlowFilterInfo> flowFilterRules) {
    if (CollectionUtils.isEmpty(flowFilterRules)) {
      return null;
    }
    List<ClientFlowFilterInfo> list = new ArrayList<>();
    flowFilterRules.forEach(f -> {
      list.add(new ClientFlowFilterInfo(f));
    });

    return list;
  }

  public ClientFlowFilterInfo(FlowFilterInfo flowFilterRule) {
    this.id = flowFilterRule.getId();
    this.code = flowFilterRule.getCode();
    this.filterName = flowFilterRule.getFilterName();
    this.type = flowFilterRule.getType();
    this.pattern = flowFilterRule.getPattern();
  }
}
